rename config to annex.security.allowed-compute-programs
authorJoey Hess <joeyh@joeyh.name>
Mon, 3 Mar 2025 20:07:04 +0000 (16:07 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 3 Mar 2025 20:12:03 +0000 (16:12 -0400)
And require for enable as well as autoenable.

It seemed asking for trouble for `git-annex enable foo` to use whatever
compute program is stored in the git config, without verifying that the
user wants that program to be used.

Note that it would be good to allow `git-annex enable foo program=...`
to be used without the program being in the git config. Not implemented yet
though.

Remote/Compute.hs
TODO-compute
Types/GitConfig.hs
doc/git-annex.mdwn
doc/special_remotes/compute.mdwn

index d43e745e952461193a23cc73afff27ccefe22f83..2903f926b2c3911e7e93d536ab9f0e0bc73199f2 100644 (file)
@@ -121,21 +121,19 @@ gen r u rc gc rs = case getComputeProgram' rc of
 setupInstance :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID)
 setupInstance ss mu _ c _ = do
        ComputeProgram program <- either giveup return $ getComputeProgram' c
+       allowedprograms <- maybe [] words . annexAllowedComputePrograms
+               <$> Annex.getGitConfig
        case ss of
-               AutoEnable _ -> do
-                       l <- maybe [] words 
-                               . annexAutoEnableComputePrograms
-                               <$> Annex.getGitConfig
-                       unless (program `elem` l) $ do
-                               let remotename = fromMaybe "(unknown)" (lookupName c)
-                               giveup $ unwords
-                                       [ "Not auto-enabling compute special remote"
-                                       , remotename
-                                       , "because its compute program"
-                                       , program
-                                       , " is not listed in annex.security.autoenable-compute-programs"
-                                       ]
-               _ -> noop
+               Init -> noop
+               _ -> unless (program `elem` allowedprograms) $ do
+                       let remotename = fromMaybe "(unknown)" (lookupName c)
+                       giveup $ unwords
+                               [ "Not enabling compute special remote"
+                               , remotename
+                               , "because its compute program"
+                               , program
+                               , "is not listed in annex.security-allowed-compute-programs"
+                               ]
        unlessM (liftIO $ inSearchPath program) $
                giveup $ "Cannot find " ++ program ++ " in PATH"
        u <- maybe (liftIO genUUID) return mu
index 547730914e1ee7838b1682b95cf12512f269eddb..3d02d9cc00b2cf79874c8dd5fe461fed4e3920e0 100644 (file)
@@ -1,3 +1,6 @@
+* allow git-annex enableremote with program= explicitly specified,
+  without checking annex.security.allowed-compute-programs
+
 * need progress bars for computations and implement PROGRESS message
 
 * get input files for a computation (so `git-annex get .` gets every file,
index 6ea4503d1a8936ad5c814e278c9791a429f0f8ba..eeae1a0c7ee2b42af2f04f9be0011ffc0e5c83f0 100644 (file)
@@ -146,7 +146,7 @@ data GitConfig = GitConfig
        , annexAllowedUrlSchemes :: S.Set Scheme
        , annexAllowedIPAddresses :: String
        , annexAllowUnverifiedDownloads :: Bool
-       , annexAutoEnableComputePrograms :: Maybe String
+       , annexAllowedComputePrograms :: Maybe String
        , annexMaxExtensionLength :: Maybe Int
        , annexMaxExtensions :: Maybe Int
        , annexJobs :: Concurrency
@@ -262,8 +262,8 @@ extractGitConfig configsource r = GitConfig
                getmaybe (annexConfig "security.allowed-http-addresses") -- old name
        , annexAllowUnverifiedDownloads = (== Just "ACKTHPPT") $
                getmaybe (annexConfig "security.allow-unverified-downloads")
-       , annexAutoEnableComputePrograms =
-               getmaybe (annexConfig "security.autoenable-compute-programs")
+       , annexAllowedComputePrograms =
+               getmaybe (annexConfig "security.allowed-compute-programs")
        , annexMaxExtensionLength = getmayberead (annexConfig "maxextensionlength")
        , annexMaxExtensions = getmayberead (annexConfig "maxextensions")
        , annexJobs = fromMaybe NonConcurrent $ 
index 214610445688a7dded6ed17ad4b1f9c60feed85c..5a39aa3bfa4297cb83bc8fa284abe0efef9a5214 100644 (file)
@@ -2201,12 +2201,12 @@ Remotes are configured using these settings in `.git/config`.
 
   Per-remote configuration of annex.security.allow-unverified-downloads.
 
-* `annex.security.autoenable-compute-programs`
+* `annex.security.allowed-compute-programs`
 
   This is a space separated list of compute programs eg
   "git-annex-compute-foo git-annex-compute-bar". Listing a compute
   program here allows compute special remotes that use that program to be
-  autoenabled.
+  enabled by `git-annex enableremote` or autoenabled.
 
 # CONFIGURATION OF ASSISTANT
 
index 811640e2f6e12eb3ca050c087335f373bb8ace7d..264cec825ae5a0c5168a40c17b34946f0ba9dcdc 100644 (file)
@@ -15,11 +15,10 @@ program to use to compute the contents of annexed files. It must start with
 "git-annex-compute-". The program needs to be installed somewhere in the
 `PATH`.
 
-The `autoenable` parameter can be set to "true" like with other special
-remotes to make git-annex automatically enable this special remote when
-run in a new clone of the repository. However, for security, autoenabling
-is only done when the git config `annex.security.autoenable-compute-programs`
-includes the name of the compute program.
+Any program can be passed to `git-annex initremote`. However, when enabling
+a compute special remote later with `git-annex enableremote` or due to
+"autoenable=true", the program must be listed in the git config
+`annex.security.allowed-compute-programs`.
 
 All other "field=value" parameters passed to `initremote` will be passed
 to the program when running [[git-annex-addcomputed]]. Note that when the